package com.bwie.controller;

import com.bwie.pojo.TbGoods;
import com.bwie.service.GoodsService;
import com.bwie.utils.R;
import com.bwie.vo.LoginVo;
import com.bwie.vo.PageVo;
import org.apache.kafka.common.security.auth.Login;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Title:
 * @BelongProjecet zk3
 * @BelongPackage com.bwie.controller
 * @Description:
 * @Copyright 研发一部
 * @Author: Mr.yan
 * @Date: 2024/6/12 9:35
 * @Version V1.0
 */
@RestController
@RequestMapping(value = "/goods/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 9:47
     * @param: 文件上传
     * @param file
     * @return com.bwie.utils.R
     */
    @PostMapping("/uploadFile")
    public R uploadFile(
            @RequestPart(value = "file")MultipartFile file
            ){
        return goodsService.uploadFile(file);
    }

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 9:47
     * @param: 视频断点上传
     * @param file
     * @return com.bwie.utils.R
     */
    @PostMapping("/uploadVideo")
    public R uploadVideo(
            @RequestPart(value = "file")MultipartFile file
    ){
        return goodsService.uploadVideo(file);
    }
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 9:53
     * @param: 秒杀商品展示+分页+模糊查询
     * @param pageVo
     * @return com.bwie.utils.R
     */
    @PostMapping("/goodsList")
    public R goodsList(
            @RequestBody PageVo pageVo
            ){
        return goodsService.goodsList(pageVo);
    }
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 10:43
     * @param: 新增抢购商品
     * @param tbGoods
     * @return com.bwie.utils.R
     */
    @PostMapping("/addGoods")
    public R addGoods(
            @RequestBody TbGoods tbGoods
            ){
        return goodsService.addGoods(tbGoods);
    }

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 10:42
     * @param: 抢购
     * @param id
     * @param token
     * @return com.bwie.utils.R
     */
    @PostMapping("/addOrder/{id}")
    public R addOrder(
            @PathVariable Integer id,//需要抢购的商品id
            @RequestHeader(value = "token")String token
    ){
        return goodsService.addOrder(token,id);
    }
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 11:20
     * @param: 展示订单列表
     * @param token
     * @return com.bwie.utils.R
     */
    @PostMapping("/orderList")
    public R orderList(
            @RequestHeader(value = "token")String token
    ){
        return goodsService.orderList(token);
    }

    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 14:18
     * @param: 展示商品类型
     * @return com.bwie.utils.R
     */
    @PostMapping("/typeList")
    public R typeList(){
        return goodsService.typeList();
    }

    @PostMapping("/feignLogin")
    public R feignLogin(
            @RequestBody LoginVo loginVo
            ){
        return goodsService.feignLogin(loginVo);
    }


}
